package com.per.mybootall.mqtt;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;


/**
 * 触发mqtt的定时任务==》》》
 * */
@Component
@EnableScheduling
public class MqttJob {
    @Resource
    private RestHighLevelClient restHighLevelClient;
    @Value("${mqtt.url}")
    private String  broker;

    @Value("${mqtt.username}")
    private String username;

    @Value("${mqtt.password}")
    private String password;

    @Value("${mqtt.client.id}")
    private String clientId;

    @Scheduled(cron = "0/30 * * * * ?")
    public void runfirst() throws IOException, InterruptedException {
//        MqttPushClient mqttPushClient=new MqttPushClient();
//        System.out.println("进入mqtt的推送=》》");
//      String  message = "Hello World =================>>>>>>>>>>>>>>>>>>>>>";
//        int qos = 2;
//        String subTopic = "testtopic/#";
//        mqttPushClient.send(message,qos,subTopic,broker,username,password,clientId);
    }
}
